<template>
  <div class="myInfo">
    <div class="title">
      <span>转账记录</span>
    </div>
    <div class="store">
      <table class="head">
        <th width="5%">序号</th>
        <th width="20%">店铺名</th>
        <th width="5%">提现金额</th>
        <th width="5%">划账金额</th>
        <th width="20%">账号</th>
        <th width="10%">开户行</th>
        <th width="5%">开户人</th>
        <th width="10%">划账时间</th>
        <th width="10%">是否划账</th>
        <th width="10%">操作</th>
      </table>
      <table class="body">
        <tr v-for="(item,index) in accountData" :key="index">
          <td width="5%">{{index+1+(curPage-1)*size}}</td>
          <td width="20%">{{item.storeName}}</td>
          <td width="5%">{{item.amount}}</td>
          <td width="5%">{{item.accountingAmount}}</td>
          <td width="20%">{{item.accountPayee}}</td>
          <td width="10%">{{item.bankName?item.bankName:"暂无"}}</td>
          <td width="5%">{{item.accountPeople}}</td>
          <!-- <td width="10%">{{item.accountingTime ? (item.accountingTime | dateForGradePage("yyyy-MM-dd hh:mm:ss")):"暂无"}}</td> -->
          <td width="10%">{{item.accountingTime | dateForGradePage("yyyy-MM-dd hh:mm:ss")}}</td>
          <td width="10%" :class="item.accounting?'':'not-account'">{{item.accounting?"已划账":"未划账"}}</td>
          <td width="10%" @click="doDeal(item)">确认划账</td>
        </tr>
      </table>
    </div>
    <div class="page right">
      <el-pagination background layout="prev, pager, next" :page-size="size" :total="totalElements" @current-change="handleCurrentChange">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import {BASE_URL} from "./../../urlConfig/index";
export default {
  data() {
    return {
      accountData: [],
      size: 10,
      totalElements: 0,
      curPage: 1 //当前页
    };
  },
  methods: {
    handleCurrentChange(val) {
      this.getAllData(val - 1);
      this.curPage = val;
    },
    doDeal(item) {
      if (item.accounting) {
        return;
      }
      this.$http({
        url: BASE_URL+"v1/call/update-storeAccount",
        method: "POST",
        data: {
          id: item.id,
          accounting: 1
        }
      }).then(res => {
        console.log(res);
        this.$message({
          message: "划账成功",
          type: "success"
        });
        this.getAllData(this.curPage - 1);
      });
    },
    getAllData(page) {
      this.$http({
        url: BASE_URL+"v1/call/get-storeAccount",
        method: "GET",
        params: {
          page,
          size: this.size
        }
      }).then(res => {
        console.log(res);
        this.accountData = res.data.content;
        this.totalElements = res.data.totalElements;
      });
    }
  },
  created: function() {},
  mounted() {
    this.getAllData(0);
  }
};
</script>
<style lang="scss" scoped>
@import "./withDraw.scss";
</style>
